<!--
 * @Author: fengxx
 * @Date: 2025-09-17 14:12:04
 * @LastEditors: fengxx
 * @LastEditTime: 2025-09-18 10:38:47
-->
<script setup lang="ts">
import { computed } from 'vue'

const visible = defineModel('visible', {
  type: Boolean,
  required: true,
})
const currentProduct = defineModel('currentProduct', {
  type: Object,
})

const emit = defineEmits(['visibleChange'])

// const dialogVisible1 = computed(() => props.dialogVisible)

const submit = () => {
  // fetch()
  visible.value = false
  emit('visibleChange')
}

const cancel = () => {
  visible.value = false
}

const modalTitle = computed(() => {
  return currentProduct.value.date ? '编辑' : '新增'
})
</script>
<template>
  <el-dialog v-model="visible" :title="modalTitle" width="500" destroy-on-close>
    <el-form ref="ruleFormRef" style="max-width: 600px" :model="currentProduct" label-width="auto">
      <el-form-item label="日期" prop="date">
        <el-input v-model="currentProduct.date" />
      </el-form-item>
      <el-form-item label="名称" prop="name">
        <el-input v-model="currentProduct.name" />
      </el-form-item>
      <el-form-item label="地址" prop="address">
        <el-input v-model="currentProduct.address" />
      </el-form-item>
    </el-form>
    <template #footer>
      <div class="dialog-footer">
        <el-button @click="cancel">Cancel</el-button>
        <el-button type="primary" @click="submit"> 提交 </el-button>
      </div>
    </template>
  </el-dialog>
</template>
